//
//  TZHomeModel.m
//  OurFramework
//
//  Created by 949699582 on 2019/8/5.
//  Copyright © 2019 com.cunyin.paywaiter. All rights reserved.
//

#import "TZHomeModel.h"
#import "AFNetworking.h"
#import "YYKit.h"
#import "NSObject+YYModel.h"
#import "TZHomeModel.h"
@implementation TZHomeModel

-(void)getDataSuccess:(Success)success AndFailure:(Failure)failure page:(int)page count:(int)count{
    
    AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
    
    NSString *str = [NSString stringWithFormat:@"%@&page=%d&count=%d",test_jokes,page,count];
    
    [session GET:str parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        
        NSNumber *number = [responseObject valueForKey:@"code"] ;
        if([number isEqualToNumber:[NSNumber numberWithInt:200]])
        {
            NSArray *data = [responseObject valueForKey:@"result"];
            NSArray *dataArray = [NSArray modelArrayWithClass:[TZHomeModel class] json:data];
            
//            for (TZHomeModel *model in dataArray)
//            {
//                [model setupViewModel];
//            }
            
            success(dataArray);
        }
    }
         failure:^(NSURLSessionDataTask *task, NSError *error)
     {
         
         
         failure(@"获取数据失败");
     }];
    
}

//初始化供view用的一些参数
- (void)setupViewModel
{
    NSLog(@"初始化Home Model");
}

@end
